<template>
    <van-search v-model="sear" show-action label="地址" placeholder="请输入搜索关键词" @search="onSearch"></van-search>
<div v-if="sear.length==0||searchApiData.length==0">
    <van-empty description="描述文字" />
</div>
        <van-card v-else v-for="item in searchApiData" :price="item.goods_price"  :title="item.goods_name"
            :thumb="item.goods_big_logo ?item.goods_big_logo:'https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg'" />
</template>

<script setup>
import { searchApi } from "@/api/api";
import { ref, watch } from 'vue';
let sear = ref('')
// 防抖
const searchApiData=ref([])
watch(sear,(val) => {
    console.log('监听到的数据', val);
    searchApi(val).then(res => {
        console.log('搜索数据', res);
        searchApiData.value=res.data.message.goods
    })
})

</script>

<style lang="scss" scoped></style>